{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\pe52\Dropbox\Research\ECM\EquationBalanceNote\PSRM_Replication\EnnsWlezien_Tables_1_2_StataVersion13.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 3 Feb 2018, 12:59:04

{com}. do "C:\Users\pe52\Dropbox\Research\ECM\EquationBalanceNote\PSRM_Replication\EnnsWlezien_Tables1_2_StataVersion13.1.do"
{txt}
{com}. ****************************************
. **Peter K. Enns and Christopher Wlezien
. **Understanding Equation Balance in Time Series Regression: An Extension
. **Political Science Research Methods
. **Simulation Code to Replicate Tables 1 and 2
. **and results reported in footnotes 15 & 16
. ****************************************
. 
. **All simulations are conducted in Stata 13
. 
. **********************
. **********************
. *TABLE 1
. **********************
. **********************
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 1, \theta_x = 0$, T=50{c )-}{c )-}
. 
. *\begin{c -(}verbatim{c )-}
. *Show current version
. version
{txt}version 14.2

{com}. *Set to Stata version 13.1
. version 13.1
{txt}
{com}. set seed 4545
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 50
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u if t==1
{txt}  6{com}.         replace y=y[_n-1] + u if t>1
{txt}  7{com}.         gen e1=invnorm(uniform())
{txt}  8{com}.         gen x1=e1
{txt}  9{com}.                 tsset t
{txt} 10{com}.                 reg y l.y x1 l.x1
{txt} 11{com}.                 estat bgodfrey
{txt} 12{com}.                 mat P = r(p)
{txt} 13{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 14{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         65    .0262727    .0146876   .0014023   .0487564
{txt}
{com}. 
. **********
. ***TABLE 1, T=50, \theta_x=0
. **********
. 
. *T=50, \beta_1
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000    .0032411    .1442302  -.4523138   .4442618
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. *critical value set to 2.01 because T=50
. sum tstat_x1 if tstat_x1>=2.01 

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         42    2.398419    .4051894   2.023164   3.708802
{txt}
{com}. 
. *T=50, \beta_2
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000   -.0020699    .1475633  -.5336888   .5544686
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=2.01

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         54      2.3987    .3548187   2.012449   3.396571
{txt}
{com}. 
. *alpha (Foonote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .8970247    .0870859   .3515186   1.077486
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 1, \theta_x = 0$, T=1,000{c )-}{c )-}
. 
. *\begin{c -(}verbatim{c )-}
. set seed 4545
{txt}
{com}. program drop unitroot
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 1000
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u if t==1
{txt}  6{com}.         replace y=y[_n-1] + u if t>1
{txt}  7{com}.         gen e1=invnorm(uniform())
{txt}  8{com}.         gen x1=e1
{txt}  9{com}.                 tsset t
{txt} 10{com}.                 reg y l.y x1 l.x1
{txt} 11{com}.                 estat bgodfrey
{txt} 12{com}.                 mat P = r(p)
{txt} 13{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 14{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         46     .023894    .0140775   .0019538   .0487054
{txt}
{com}. 
. **********
. ***TABLE 1, T=1,000, \theta_x=0
. **********
. 
. *T=1,000, \beta_1
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000   -.0011346    .0313375  -.1252477   .0868904
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         48    2.356429    .3602112   1.965033   3.872185
{txt}
{com}. 
. *T=1,000 \beta_2
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000     .000329    .0301322  -.0945426   .1025092
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         50    2.268798    .3041645   1.972812   3.259358
{txt}
{com}. 
. *alpha (Footnote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000     .994644    .0044886   .9663107   1.003344
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 1, \theta_x = .5$, T=50{c )-}{c )-}
. *\begin{c -(}verbatim{c )-}
. 
. set seed 4545
{txt}
{com}. program drop unitroot
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 50
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u if t==1
{txt}  6{com}.         replace y=y[_n-1] + u if t>1
{txt}  7{com}.         gen e1=invnorm(uniform())
{txt}  8{com}.         gen x1=e1 if t==1
{txt}  9{com}.     replace x1=.5*x[_n-1] + e1 if t>1
{txt} 10{com}.                 tsset t
{txt} 11{com}.                 reg y l.y x1 l.x1
{txt} 12{com}.                 estat bgodfrey
{txt} 13{com}.                 mat P = r(p)
{txt} 14{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 15{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         64    .0260986    .0139656   .0009286   .0497507
{txt}
{com}. 
. **********
. ***TABLE 1, T=50, \theta_x=0.5
. **********
. 
. *T=50, \beta_1, \theta_x=0.5
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000    .0025005    .1457209   -.484118   .4392033
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=2.01

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         42    2.435827    .4135578   2.010762   3.866026
{txt}
{com}. 
. *T=50, \beta_2, \theta_x=0.5
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000   -.0034913    .1477989  -.4830402   .5627766
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=2.01

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         43    2.400216    .3382621   2.017996   3.500768
{txt}
{com}. 
. *alpha (Footnote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .8931965    .0904349   .2495546   1.084391
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 1, \theta_x = .5$, T=1000{c )-}{c )-}
. *\begin{c -(}verbatim{c )-}
. set seed 4545
{txt}
{com}. program drop unitroot
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 1000
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u if t==1
{txt}  6{com}.         replace y=y[_n-1] + u if t>1
{txt}  7{com}.         gen e1=invnorm(uniform())
{txt}  8{com}.         gen x1=e1 if t==1
{txt}  9{com}.     replace x1=.5*x[_n-1] + e1 if t>1
{txt} 10{com}.                 tsset t
{txt} 11{com}.                 reg y l.y x1 l.x1
{txt} 12{com}.                 estat bgodfrey
{txt} 13{com}.                 mat P = r(p)
{txt} 14{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 15{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         46    .0236839    .0141306   .0018866   .0496753
{txt}
{com}. 
. **********
. ***TABLE 1, T=1,000, \theta_x=0.5
. **********
. 
. *T=1,000, \beta_1, \theta_x=0.5
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000   -.0011378    .0313302  -.1252613   .0869988
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         47    2.362881    .3549968   1.971177   3.872103
{txt}
{com}. 
. *T=1,000, \beta_2, \theta_x=0.5
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000    .0009862    .0310276  -.1063905   .0893032
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         43    2.297727    .3499432   1.974148    3.47455
{txt}
{com}. 
. *alpha (Footnote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .9946349    .0045031   .9657305   1.003358
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. **********************
. **********************
. *TABLE 2
. **********************
. **********************
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 0, \theta_x = 1$, T=50{c )-}{c )-}
. 
. *\begin{c -(}verbatim{c )-}
. set seed 5656
{txt}
{com}. program drop unitroot
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 50
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u
{txt}  6{com}.         gen e1=invnorm(uniform())
{txt}  7{com}.         gen x1=e1 if t==1
{txt}  8{com}.     replace x1=x1[_n-1] + e1 if t>1
{txt}  9{com}.                 tsset t
{txt} 10{com}.                 reg y l.y x1 l.x1
{txt} 11{com}.                 estat bgodfrey
{txt} 12{com}.                 mat P = r(p)
{txt} 13{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 14{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation (Footnote 15)
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         63    .0211747    .0140999   .0004236   .0466323
{txt}
{com}. 
. **********
. ***TABLE 2, T=50, \theta_y=0
. **********
. 
. *T=50, \beta_1, \theta_y=0
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000   -.0023391    .1574336  -.5938824   .5867782
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=2.01

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         60    2.422709    .4023603   2.012227   3.451088
{txt}
{com}. 
. *T=50, \beta_2, \theta_y=0
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000    .0012508    .1549475  -.5422469   .6044306
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=2.01

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         55    2.432852    .3081435   2.010204   3.158617
{txt}
{com}. 
. *alpha (Footnote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000   -.0424389    .1429048  -.4582225   .3524079
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 0, \theta_x = 1$, T=1,000{c )-}{c )-}
. 
. *\begin{c -(}verbatim{c )-}
. set seed 5656
{txt}
{com}. program drop unitroot
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 1000
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u
{txt}  6{com}.         gen e1=invnorm(uniform())
{txt}  7{com}.         gen x1=e1 if t==1
{txt}  8{com}.     replace x1=x1[_n-1] + e1 if t>1
{txt}  9{com}.                 tsset t
{txt} 10{com}.                 reg y l.y x1 l.x1
{txt} 11{com}.                 estat bgodfrey
{txt} 12{com}.                 mat P = r(p)
{txt} 13{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 14{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation (Footnote 15)
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         49    .0259284    .0127498    .000464   .0495821
{txt}
{com}. 
. **********
. ***TABLE 2, T=1,000, \theta_Y=0
. **********
. 
. *T=1,000, \beta_1, \theta_y=0
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000    .0010957    .0321077  -.0914113   .0901113
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         56    2.297421    .2905582   1.982877   2.934303
{txt}
{com}. 
. *T=1,000, \beta_2, \theta_y=0
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000   -.0009187    .0318991  -.0874224   .0934609
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         53    2.299583    .2626423    2.00234   2.845028
{txt}
{com}. 
. *alpha (Footnote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000   -.0018327    .0313944  -.1422829   .1138489
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 0.5, \theta_x = 1$, T=50{c )-}{c )-}
. 
. *\begin{c -(}verbatim{c )-}
. set seed 5656
{txt}
{com}. program drop unitroot
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 50
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u if t==1
{txt}  6{com}.         replace y=.5*y[_n-1] + u if t>1
{txt}  7{com}.         gen e1=invnorm(uniform())
{txt}  8{com}.         gen x1=e1 if t==1
{txt}  9{com}.     replace x1=x[_n-1] + e1 if t>1
{txt} 10{com}.                 tsset t
{txt} 11{com}.                 reg y l.y x1 l.x1
{txt} 12{com}.                 estat bgodfrey
{txt} 13{com}.                 mat P = r(p)
{txt} 14{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 15{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation (Footnote 15)
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         52    .0254819    .0146639    .000659   .0499174
{txt}
{com}. 
. **********
. ***TABLE 2, T=50, \theta_y=0.5
. **********
. 
. *T=50, \beta_1, \theta_y=0.5
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000   -.0034072     .158147  -.6000501   .5976261
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=2.01

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         64    2.403372    .4001168   2.014436   3.383662
{txt}
{com}. 
. *T=50, \beta_2, \theta_y=0.5
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000    .0015077    .1550613  -.5476673   .6021846
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=2.01

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         60    2.400952    .3128192   2.024926   3.236836
{txt}
{com}. 
. *alpha (Footnote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .4182209    .1375631  -.1115555    .749405
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. 
. *\subsection{c -(}\textbf{c -(}No Relationship, $\theta_y = 0.5, \theta_x = 1$, T=1,000{c )-}{c )-}
. 
. *\begin{c -(}verbatim{c )-}
. set seed 5656
{txt}
{com}. program drop unitroot
{txt}
{com}. program define unitroot, rclass
{txt}  1{com}.         drop _all
{txt}  2{com}.         set obs 1000
{txt}  3{com}.         gen t = _n
{txt}  4{com}.         gen u=invnorm(uniform())
{txt}  5{com}.         gen y=u if t==1
{txt}  6{com}.         replace y=.5*y[_n-1] + u if t>1
{txt}  7{com}.         gen e1=invnorm(uniform())
{txt}  8{com}.         gen x1=e1 if t==1
{txt}  9{com}.     replace x1=x[_n-1] + e1 if t>1
{txt} 10{com}.                 tsset t
{txt} 11{com}.                 reg y l.y x1 l.x1
{txt} 12{com}.                 estat bgodfrey
{txt} 13{com}.                 mat P = r(p)
{txt} 14{com}.                 return scalar pvalue_bg = P[1,1] 
{txt} 15{com}. end
{txt}
{com}. 
. *Simulate the program "unitroot" N times and save the betas and standard errors.
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(1000) nodots: unitroot
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}unitroot{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many 
. *regressions we would incorrectly reject the null hypothesis
. 
. *Percent of simulations which a Breusch-Godfrey test rejects teh null of 
. *no serial correlation (Footnote 15)
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}         33    .0237616    .0149232   .0002778   .0492218
{txt}
{com}. 
. **********
. ***TABLE 2, T=1,000, \theta_y=0.5
. **********
. 
. *T=1,000, \beta_1, \theta_y=0.5
. sum _b_x1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      1,000    .0011034    .0320655  -.0908177   .0907087
{txt}
{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}         55    2.297615    .2934678    1.97059   2.952643
{txt}
{com}. 
. *T=1,000, \beta_2, \theta_y=0.5
. sum _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_3 {c |}{res}      1,000   -.0009221    .0318574  -.0880615   .0928688
{txt}
{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}         52    2.298549    .2677508   1.976151   2.864505
{txt}
{com}. 
. *alpha (Footnote 16)
. sum _sim_1

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .4964201    .0275435   .3720207   .5731742
{txt}
{com}. *\end{c -(}verbatim{c )-}
. 
. 
{txt}end of do-file

{com}. program drop unitroot

. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\pe52\Dropbox\Research\ECM\EquationBalanceNote\PSRM_Replication\EnnsWlezien_Tables_1_2_StataVersion13.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res} 3 Feb 2018, 13:33:16
{txt}{.-}
{smcl}
{txt}{sf}{ul off}